Imports System.Text

Friend Class DBConnectSummary_Factory
    Inherits DBBase

    Public Function GetExistingSummary( _
        ByVal sDate As Date, _
        ByVal lDatabaseID As Long) As ConnectSummary

        Dim oConnectSummary As ConnectSummary = Nothing

        Dim sSQL As New StringBuilder("select")
        With sSQL
            .Append(" ID")
            .Append(" from")
            .Append(" ConnectSummary")
            .Append(" where")
            .Append(" [databaseID]=" & lDatabaseID)
            .Append(" and [year]=" & sDate.Year)
            .Append(" and [month]=" & sDate.Month)
            .Append(" and [day]=" & sDate.Day)
            .Append(" and [hour]=" & sDate.Hour)
        End With

        Dim oValue As Object = MyBase.ExecuteScalar(sSQL.ToString)

        If IsNumeric(oValue) Then
            oConnectSummary = New ConnectSummary(Val(oValue))
            oConnectSummary.Load()
        End If

        Return oConnectSummary
    End Function

End Class
